import Mock from "mockjs";
import type { Request } from "express";

export default [
  // 用户列表数据
  {
    method: "get",
    url: "/api/customers",
    response: (req: Request) => {
      // 页码
      let page = req.query.page ? Number(req.query.page) : 1;
      // 每页要显示的记录条数，默认为5条
      let size = req.query.size ? Number(req.query.size) : 5;
      let total = 50;
      //学位
      const randomAgree = ["外星人","本科","硕士","博士"]
      //电话
      const randomNumber = [15127890173,13833828281,15128576748,13098982157,15731247890,1782828989]

      const userData = Mock.mock({
        "users|5": [
          {
            "id|+1": (page-1) * size + 1,
            username: "@cname()",
            "sex|1": ["男", "女"],
            "age|21-48": 0,
            region: ["北京", "昌平"],
            avatar: "@image('50x100', '#50B347', '#FFF', 'Mock')",
            cdate: '@date("yyyy-MM-dd")',
            "heigh|160-195": 0,
            "weigh|60-90": 0,
            from: "安徽",
            love: "撕报纸",
            school: "山河大学",
            major: "山河经理",  
            "agree|1": randomAgree,
            "callNumber|1":randomNumber,
            headImg:
              "https://cdn7.axureshop.com/demo/2207162/images/%E6%8E%A8%E8%8D%90/u288.png",
            img: "https://cdn7.axureshop.com/demo/2207162/images/%E5%AE%A2%E6%88%B7%E5%88%97%E8%A1%A8/u2528.svg",
          },
        ],
      });
      return {
        code: 0,
        msg: "ok",
        data: {
          ...userData,
          total,
        },
      };
    },
  },
  {
    method: "post",
    url: "/api/selectUsers",
    response: (req: Request) => {
      // 页码
      let page = req.query.page ? Number(req.query.page) : 1;
      // 每页要显示的记录条数，默认为5条
      let size = req.query.size ? Number(req.query.size) : 5;
      let total = 4;
      const userData = Mock.mock({
        "users|4": [
          {
            "id|+1": (page-1) * size + 1,
            username: "@cname()",
            "sex|1": ["男", "女"],
            "age|1-110": 5,
            region: ["河北", "衡水"],
            avatar: "@image('50x100', '#50B347', '#FFF', 'Mock')",
            cdate: '@date("yyyy-MM-dd")',
            "heigh|160-195": 0,
            "weigh|60-90": 0,
            from: "安徽",
            love: "撕报纸",
            school: "山河大学",
            major: "山河经理",
            agree: "本科",
            callNumber:15127890173,
            headImg:
              "https://cdn7.axureshop.com/demo/2207162/images/%E6%8E%A8%E8%8D%90/u288.png",
            img: "https://cdn7.axureshop.com/demo/2207162/images/%E5%AE%A2%E6%88%B7%E5%88%97%E8%A1%A8/u2528.svg",
          },
        ],
      });
      return {
        code: 0,
        msg: "ok",
        data: {
          ...userData,
          total,
        },
      };
    },
  },
  {
    method: "post",
    url: "/api/upload",
    response: (req: Request) => {
      return {
        code: 0,
        msg: "ok",
        data: {
          message:"上传成功"
        },
      };
    },
  },
];
